﻿
using System.Collections.Generic;
using System.Data;
using System;
namespace ZHDJ.MobileInterface
{
    public partial class GetPartyHistory : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            PartyHistoryOutParam result = new PartyHistoryOutParam();
            PartyHistoryInParam param = new PartyHistoryInParam();
            string logMsg = "";
            bool isFlag = true;
                 
            try
            {
                param = inParam as PartyHistoryInParam;  

                if(isFlag)
                {
                    PartyHistory itemTemp;
                    result.data.total_pages = 1;// CommonUtils.GetTotalPages(Convert.ToInt32(ds.Tables[0].Rows[0][0]), param.page_count);

                    itemTemp = new PartyHistory();
                    itemTemp.file_id = "6DE6F6DA2B0349C9855966CAFE431111";
                    itemTemp.name = "身边党史";
                    itemTemp.size = "101";
                    itemTemp.type = "";
                    itemTemp.url = "http://www.ith71.cn/Widgets/Pages/PartyJewelBox/Hostory/身边党史.rar";

                    result.data.list.Add(itemTemp);
                }
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员"; 
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-GetPartyHistoryList", SerializeHelper.JsonSerializer<PartyHistoryInParam>(param), logMsg); 
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<PartyHistoryInParam, PartyHistoryOutParam>();
            else
                SafeProcessRequest<PartyHistoryInParam, PartyHistoryOutParam>();
        }
    }

    #region 请求参数
    public class PartyHistoryInParam
    {  
        /// <summary>
        /// 类别
        /// </summary>
        public string type
        { get; set; }

        /// <summary>
        /// 必填 当前页
        /// </summary>
        public int page_no
        { get; set; }

        /// <summary>
        /// 必填，每页记录条数
        /// </summary>
        public int page_count
        { get; set; }
    }
    #endregion

    #region 结果参数
    public class PartyHistoryOutParam
    {
        public PartyHistoryOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new PartyHistoryList();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 党情速递信息列表
        /// </summary>
        public PartyHistoryList data
        { get; set; }
    }

    public class PartyHistoryList
    {
        public PartyHistoryList()
        {
            total_pages = 0;
            list = new List<PartyHistory>();
        }

        public List<PartyHistory> list { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int total_pages
        { get; set; }
    }
     
    /// <summary>
    /// 信息
    /// </summary>
    public class PartyHistory
    {
        /// <summary>
        ///	附件ID
        /// </summary>
        public string file_id
        { get; set; }
        /// <summary>
        ///	附件名称	
        /// </summary>
        public string name
        { get; set; }
        /// <summary>
        ///	附件类型	
        /// </summary>
        public string type
        { get; set; }
        /// <summary>
        ///	附件大小	
        /// </summary>
        public string size
        { get; set; }
        /// <summary>
        ///	附件下载地址	
        /// </summary>
        public string url
        { get; set; } 
    }
    #endregion 
}